using System.Collections.Generic;
using System.Data.Objects;
using Magiq.Databases;
using Magiq.Support;

namespace Magiq.Providers.Entities.Insert
{
    public class InsertObjectSet<TDestination, TNew> : DatabaseOperation, IInsertDestination<TNew> where TNew : TDestination where TDestination : class
    {
        private readonly ObjectSet<TDestination> objectSet;

        public InsertObjectSet(ObjectSet<TDestination> objectSet, LinqToEntitiesAdapter linqToEntitiesAdapter)
        {
            OrmAdapter = linqToEntitiesAdapter;
            this.objectSet = objectSet;
        }

        #region IInsertDestination<TNew> Members

        public void Insert(IEnumerable<TNew> items)
        {
            foreach (var item in items)
                objectSet.AddObject(item);
        }

        #endregion
    }
}